package com.supplychain.scm.core.http.client.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName OkHttpProperties
 * @createTime 14:15:00 2023/01/10
 */
@Data
@RefreshScope
@ConfigurationProperties(prefix = OkHttpProperties.PREFIX)
public class OkHttpProperties {

    /**
     * 前缀
     */
    public static final String PREFIX = "dby.okhttp";

    /**
     * 是否开启
     */
    private boolean enabled;
    /**
     * 最大空闲连接数
     */
    private int maxIdleConnections = 200;
    /**
     * 保持活动持续时间(单位：秒)
     */
    private long keepAliveDuration = 300;
    /**
     * 连接池配置
     */
    private Pool pool = new Pool();

    @Data
    public static class Pool{
        /**
         * 连接失败时重试
         */
        private boolean retryOnConnectionFailure = true;
        /**
         * 连接超时时间（单位：秒）
         */
        private long connectTimeout = 10;
        /**
         * 读取超时时间（单位：秒）
         */
        private long readTimeout = 10;
        /**
         * 写入超时时间（单位：秒）
         */
        private long writeTimeout = 10;
        /**
         * 主机验证
         */
        private boolean hostnameVerifier = true;
    }
}
